<?php 
class Modelstockfactory extends Model {


	public function getList($page,$filter){
		$filter['refer_type_id']=2;
		$list =  M('money_out')
				->field('sum(money_out.payables) as payables ,sum(money_out.refer_total) as refer_total,sum(money_out.paid) as paid,payee_id,payee')
				->group('payee_id')
				->where($filter)
				->page($page)->limit($this->config->get('config_limit_admin'))->select();
				echo  M('money_out')->getLastsql();
			return $list;

	}

	public function getCount($filter){
		$filter['refer_type_id']=2;
		$list =  M('money_out')
				->field('payee_id')
				->group('payee_id')
				->where($filter)
				->select();
		return $list;
	}

	public function getMoneyOut($payer_id){

	    $money_out =M('money_out')
	    		->join('left join  `refer_type` r on r.refer_type_id=money_out.refer_type_id')
				->join('left join  `money_out_status` s on s.money_out_status_id=money_out.status')
				->field('money_out.*,r.name,s.name as status_name')->where(array('payee_id'=>$payer_id,'status'=>1))->select();

	    return $money_out;
	}
	

	public function getAutoCompletefactory($filter_name){
		$where = "`vendor_name` LIKE '%".$filter_name."%'" ; 
	    $user = M('vendors')
				->field('user_id,vendor_name')->where($where)->limit(10)->select();
			 // echo M('user')->getLastsql();

	    return $user;
	}

}